package com.eds.ailipay.utils;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class AliPayUtil {
    @Value("${alipay.appId}")
    private String appId;
    @Value("${alipay.serverUrl}")
    private String serverUrl;
    @Value("${alipay.privateKey}")
    private String privateKey;
    @Value("${alipay.publicKey}")
    private String publicKey;
    @Value("${alipay.charset}")
    private String charset;

    @Value("${alipay.format}")
    private String format;
    @Value("${alipay.signType}")
    private String signType;

    @Bean
    public AlipayClient getAlipayClient() {
        return new DefaultAlipayClient(serverUrl, appId, privateKey, "json", charset, publicKey, "RSA2");
    }
}
